<!--
 * @Description: 
 * @Author: baron
 * @Date: 2025-04-15 13:28:27
 * @LastEditTime: 2025-04-16 17:32:02
 * @LastEditors: baron
-->
<script>
import { hasLogin } from '@/utils/login';
export default {
    onLaunch() {
        try {
            // 获取系统信息
            const systemInfo = wx.getSystemInfoSync();
            // 假设导航栏高度为状态栏高度 + 胶囊按钮高度 + 间距(通常为8)
            const navBarHeight = systemInfo.statusBarHeight + 44;
            const tabBarHeight = systemInfo.screenHeight - systemInfo.safeArea.bottom + 44;

            uni.setStorageSync('navBarHeight', navBarHeight);
            uni.setStorageSync('tabBarHeight', tabBarHeight);
            uni.setStorageSync('platform', systemInfo.platform);
            uni.setStorageSync('environment', systemInfo.environment);
            console.log('获取的系统信息', systemInfo);
        } catch (e) {
            // Do something when catch error
        }
    },
    onShow() {
        const updateManager = wx.getUpdateManager();
        updateManager.onCheckForUpdate(function (res) {
            // 请求完新版本信息的回调
            console.log(res);
        });
        const fs = wx.getFileSystemManager();
        fs.getSavedFileList({
            success: savedFileInfo => {
                let list = savedFileInfo.fileList;
                for (let i = 0; i < list.length; i++) {
                    fs.removeSavedFile({
                        filePath: list[i].filePath
                    });
                }
            }
        });
        updateManager.onUpdateReady(function () {
            wx.showModal({
                title: '更新提示',
                showCancel: false,
                content: '新版本已经准备好，是否重启应用？',
                success: function (res) {
                    if (res.confirm) {
                        // 新的版本已经下载好，调用 applyUpdate 应用新版本并重启
                        updateManager.applyUpdate();
                    }
                }
            });
        });
    },
    onHide: function () {
        console.log('App Hide')
    }
}
</script>

<style>
/*每个页面公共css */
</style>
